package com.example.administrator.yunniuusedcar.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.bean.brand.Data;

/**
 * Created by Administrator on 2018/1/3 0003.
 */

public class TabListViewAdapter extends BaseAdapter {
    private Data data;
    private Context context;
    public TabListViewAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        if(data==null)
            return 0;
        return data.getData().size();
    }

    @Override
    public Object getItem(int i) {
        return data.getData().get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.fragment_tab_recyclerview_item,null);

        TextView car_name = (TextView)v.findViewById(R.id.car_name);
        TextView integral_range = (TextView)v.findViewById(R.id.integral_range);
        TextView member_range = (TextView)v.findViewById(R.id.member_range);
        TextView marker_price = (TextView)v.findViewById(R.id.market_price);

        car_name.setText(data.getData().get(i).getName());
        integral_range.setText(data.getData().get(i).getIntegral_range());
        member_range.setText(data.getData().get(i).getMember_range());
        marker_price.setText("市场价格"+data.getData().get(i).getMarket_price());
        return v;
    }

    public void setData(Data data) {
        this.data = data;
        notifyDataSetChanged();
    }
}
